/*
 * File: E:\Kan\ARM\Projects\Umrichter\SimulinkModelle\slprj\ert\_sharedutils\div_s16s32.c
 *
 * Code generated for Simulink model 'Fu_SensAvrg'.
 *
 * Model version                  : 1.48
 * Simulink Coder version         : 8.2 (R2012a) 29-Dec-2011
 * TLC version                    : 8.2 (Dec 29 2011)
 * C/C++ source code generated on : Mon Apr 08 20:20:49 2013
 */

#include "rtwtypes.h"
#include "rtw_shared_utils.h"

int16_T div_s16s32(int32_T numerator, int32_T denominator)
{
  int16_T quotient;
  uint32_T absDenominator;
  uint32_T quotientNeedsNegation;
  if (denominator == 0) {
    quotient = numerator >= 0 ? MAX_int16_T : MIN_int16_T;

    /* Divide by zero handler */
  } else {
    absDenominator = (uint32_T)(denominator >= 0 ? denominator : -denominator);
    quotientNeedsNegation = ((numerator < 0) != (denominator < 0));
    absDenominator = absDenominator == 0 ? MAX_uint32_T : (uint32_T)(numerator >=
      0 ? numerator : -numerator) / absDenominator;
    quotient = quotientNeedsNegation ? (int16_T)-(int32_T)absDenominator :
      (int16_T)absDenominator;
  }

  return quotient;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
